function [xticks_values, xticks_values_disp] = makeXticks4timePlot(periodLabels)
	
	NumPeriods = length(periodLabels);
	
	%%% Determine the type of period (day / week / month)
	if strcmp(class(periodLabels{1}), 'datetime')
		formatOut = 'yyyy-mm-dd';
		for pp = 1:NumPeriods
			a = periodLabels{pp};
			periodLabels{pp} = datestr(periodLabels{pp}, formatOut);
		end
	end
		
	if length(periodLabels{1}) == 10
		periodType = 'day';	% format "yyyy-mm-dd"
	end
	
	if length(periodLabels{1}) == 7
		periodType = 'month';	% format "yyyy-mm"
	end
	
	if length(periodLabels{1}) == 24
		periodType = 'week'; % format "yyyy-mm-dd to yyyy-mm-dd"
		% Take start of the week as the label to be displayed
		for pp = 1:NumPeriods
			a = periodLabels{pp};
			periodLabels{pp} = periodLabels{pp}(1:10);
		end
	end
	
	if ~exist('periodType')
		periodType = 'other';
	end
	
	%%% Determine which period labels are to be displayed
	if strcmp(periodType, 'day')
		yearStarts =  ~cellfun(@isempty,regexp(periodLabels,'01-01$'));
		monthStarts =  ~cellfun(@isempty,regexp(periodLabels,'-01$'));
		monthStarts6 =  ~cellfun(@isempty,regexp(periodLabels,'01-01$')) | ~cellfun(@isempty,regexp(periodLabels,'07-01$'));
		monthStarts3 =  ~cellfun(@isempty,regexp(periodLabels,'01-01$')) | ~cellfun(@isempty,regexp(periodLabels,'04-01$')) | ...
			~cellfun(@isempty,regexp(periodLabels,'07-01$')) | ~cellfun(@isempty,regexp(periodLabels,'10-01$'));
		monthStarts2 =  ~cellfun(@isempty,regexp(periodLabels,'01-01$')) | ~cellfun(@isempty,regexp(periodLabels,'03-01$')) | ...
			~cellfun(@isempty,regexp(periodLabels,'05-01$')) | ~cellfun(@isempty,regexp(periodLabels,'07-01$')) | ...
			~cellfun(@isempty,regexp(periodLabels,'09-01$')) | ~cellfun(@isempty,regexp(periodLabels,'11-01$'));
	end
	if strcmp(periodType, 'month')
		yearStarts =  ~cellfun(@isempty,regexp(periodLabels,'01$'));
		monthStarts =  1:NumPeriods;
		monthStarts6 =  ~cellfun(@isempty,regexp(periodLabels,'-01$')) | ~cellfun(@isempty,regexp(periodLabels,'-07$'));
		monthStarts3 =  ~cellfun(@isempty,regexp(periodLabels,'-01$')) | ~cellfun(@isempty,regexp(periodLabels,'-04$')) | ...
			~cellfun(@isempty,regexp(periodLabels,'-07$')) | ~cellfun(@isempty,regexp(periodLabels,'-10$'));
		monthStarts2 =  ~cellfun(@isempty,regexp(periodLabels,'-01$')) | ~cellfun(@isempty,regexp(periodLabels,'-03$')) | ...
			~cellfun(@isempty,regexp(periodLabels,'-05$')) | ~cellfun(@isempty,regexp(periodLabels,'-07$')) | ...
			~cellfun(@isempty,regexp(periodLabels,'-09$')) | ~cellfun(@isempty,regexp(periodLabels,'-11$'));
	end
	
	%%% Keep at most 10 period labels
	if strcmp(periodType, 'month')
		if NumPeriods <= 10; xticks_values = find(monthStarts); end;
		if NumPeriods > 10 && NumPeriods <= 20; xticks_values = find(monthStarts2); end;
		if NumPeriods > 20 && NumPeriods <= 30; xticks_values = find(monthStarts3); end;
		if NumPeriods > 30 && NumPeriods <= 60; xticks_values = find(monthStarts6); end;
		if NumPeriods > 60; xticks_values = find(yearStarts); end;
	else if strcmp(periodType, 'day')
		if NumPeriods <= 100; xticks_values = 1:10:NumPeriods;  end;
		if NumPeriods > 100 && NumPeriods <= 300; xticks_values = find(monthStarts); end;
		if NumPeriods > 300 && NumPeriods <= 600; xticks_values = find(monthStarts2); end;
		if NumPeriods > 600 && NumPeriods <= 900; xticks_values = find(monthStarts3); end;
		if NumPeriods > 900 && NumPeriods <= 1800; xticks_values = find(monthStarts6); end;
		if NumPeriods > 1800; xticks_values = find(yearStarts); end;
	else if strcmp(periodType, 'week')
		tmp = round(NumPeriods / 10);
		xticks_values = [1:tmp:NumPeriods]';
	else if strcmp(periodType, 'other')
		tmp = round(NumPeriods / 10);
		xticks_values = [1:tmp:NumPeriods]';
	end
	end
	end
	end
    xticks_values_disp = periodLabels(xticks_values);
end
